package cn.platform.controller;

import cn.platform.request.TeacherRequest;
import cn.platform.response.AResponse;
import cn.platform.response.Result;
import cn.platform.response.TeacherOptionVO;
import cn.platform.service.TeacherService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@CrossOrigin(maxAge = 3600) //允许跨域请求
@Controller
@RequestMapping("/api/teacher")
public class TeacherController1 {
    @Resource
    TeacherService teacherService;

    @RequestMapping("/list")
    @ResponseBody
    public AResponse listTeacher(@RequestBody TeacherRequest req){
        return teacherService.listTeacher(req);
    }

    /**
     * 展示所有老师姓名，同时也给对应的id
     * @return
     */
    @GetMapping("/all")
    public Result getAllTeachers() {
        log.info("获取老师列表信息");
        List<TeacherOptionVO> list = teacherService.getAllTeacherOptions();
        return Result.success(list);
    }
}